package com.cjg.javaBasics;

public class Array {
    public static void main(String[] args) {
        //foreach 循环  i 存储元素 取消了下标  变量.for
        int[] array ={1,2,3,4,5};
        for (int i : array) {
            System.out.println(i);
        }

        f(array);

        f(reverse(array));
    }
    //删除数组
    public static void f(int[] a){

        for (int i = 0; i <a.length ; i++) {
            System.out.print(a[i]);

        }
        //换行
        System.out.println();
        //换行
        System.out.print("\n");

    }
    //反转数组
    public static int[] reverse(int[] a){
        int[] b=new int[a.length];
        for (int i = 0,j=a.length-1; i <a.length ; i++,j--) {
            b[i]=a[j];
        }
       return b;

    }
}
